<?php

namespace App\Repositories\Eloquent;

use Prettus\Repository\Eloquent\BaseRepository;
use Prettus\Repository\Criteria\RequestCriteria;
use App\Repositories\Contract\RowRepository;
use App\Models\Row;
use App\Validators\RowValidator;

/**
 * Class RowRepositoryEloquent.
 *
 * @package namespace App\Repositories\Eloquent;
 */
class RowRepositoryEloquent extends BaseRepository implements RowRepository
{
    /**
     * Specify Model class name
     *
     * @return string
     */
    public function model()
    {
        return Row::class;
    }

    /**
     * @inheritDoc
     */
    public function copy(Row $row, int $projectId, int $prevId): Row
    {
        $payload = $row->only([
            'locked',
            'level',
        ]);
        $payload['prev_id'] = $prevId;
        $payload['project_id'] = $projectId;
        return $this->create($payload);
    }

    /**
     * Boot up the repository, pushing criteria
     */
    public function boot()
    {
        $this->pushCriteria(app(RequestCriteria::class));
    }
    
}
